package handler

import (
	"360video/video-api/api/reponse"
	"360video/video-api/api/request"
	"360video/video-api/config"
	__ "360video/video-srv/handler/proto"
	"github.com/gin-gonic/gin"
	"log"
)

func Register(c *gin.Context) {
	req := request.User{}
	if c.ShouldBind(&req) != nil {
		reponse.Error(c, "绑定失败")
		return
	}
	r, err := config.VideosClient.Register(c, &__.RegisterReq{
		Account:  req.Account,
		Password: req.Password,
	})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	reponse.Success(c, "注册成功", __.RegisterResp{
		Id: r.Id,
	})
}
